<template>
	<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
			
		  <el-form-item label="采购明细号" prop="dno">
			<el-input v-model="ruleForm.dno"></el-input>
		  </el-form-item>
		  <el-form-item label="采购清单号" prop="pno">
			<el-input v-model="ruleForm.pno"></el-input>
		  </el-form-item>
		  <el-form-item label="商品编号" prop="gno">
			<el-input v-model="ruleForm.gno"></el-input>
		  </el-form-item>
		  <el-form-item label="采购数量" prop="dcount">
			<el-input v-model="ruleForm.dcount"></el-input>
		  </el-form-item>
		  <el-form-item label="商品单价" prop="donemoney">
			<el-input v-model="ruleForm.donemoney"></el-input>
		  </el-form-item>
		  <el-form-item label="商品总价" prop="dtotalmoney">
			<el-input v-model="ruleForm.dtotalmoney"></el-input>
		  </el-form-item>
		  <el-form-item label="备注" prop="dremark">
		  			<el-input v-model="ruleForm.dremark"></el-input>
		  </el-form-item>
		  
	
		  <el-form-item>
			<el-button type="primary" @click="submitForm('ruleForm')">修改</el-button>
			 <el-button @click="resetForm('ruleForm')">重置</el-button>
		  </el-form-item>
	</el-form>
</template>

<script>
  export default {
	  name: "DetailUpdate",
			data() {
			  return {
				ruleForm: {
				  dno:'',
				  pno:'',
				  gno:'',
				  dcount:'',
				  donemoney:'',
				  dtotalmoney:'',				  
				  gremark:'' 
				},
				rules: {
						
				}
			  };
			},
			methods: {
			 submitForm(formName) {
				 const _this = this;
			         this.$refs[formName].validate((valid) => {
			           if (valid) {
						
							axios.put('http://localhost:8181/detail/update',this.ruleForm).then(function(resp){
								console.log(resp)
								if(resp.data == 'success'){
									_this.$message('修改成功！');
									_this.$router.push('/DetailSearch')
								}
							})
			           } else {
			             console.log('error submit!!');
			             return false;
			           }
			         });
			       },
			       resetForm(formName) {
			         this.$refs[formName].resetFields();
			       }
			     },
				 created(){
					const _this = this;
					 axios.get('http://localhost:8181/detail/findById/'+this.$route.query.id).then(function(resp){
						_this.ruleForm = resp.data
					 })
				 }
		  }
</script>

<style>
</style>
